<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>重置密码</title>
	<link rel="stylesheet" href="../../css/aui.css" />
	<link rel="stylesheet" href="../../css/my/forget_password.css">
</head>

<body style="cursor: pointer;">
	<!-- TODO: 修改密码 -->
	<ul class="aui-list aui-form-list from_padded aui-padded-t-15" style="border:none;">
		<form id="myform" role="form" action="#" method="POST">
			<li class="aui-list-item ">
				<label style="width:30%;line-height:2.2rem;">新密码:</label>
				<input type="password" name="password" id="pwd" placeholder="请输入新密码">
			</li>
			<li class="aui-list-item col_center">
				<label style="width:30%;line-height:2.2rem;">确认密码:</label>
				<input type="password" name="rePassword" placeholder="请输入确认密码">
			</li>
		</form>
		<div class="aui-btn aui-btn-block btn_padded reset" onclick="pass_submit()">确定</div>
	</ul>

</body>

</html>
<script type="text/javascript" src="../../script/aui/api.js"></script>
<script type="text/javascript" src="../../script/extend/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
	apiready = function() {
		api.parseTapmode();
	}
	// TODO: 修改密码
	function pass_submit() {
		//获取存在本地用户的手机号码
		mobile = api.pageParam.mobile;
		company_id = api.pageParam.company_id;
		password = $('input[name=password]').val();
		rePassword = $('input[name=rePassword]').val();

		if (!isDefine(password)) {
				$toast('请填写新密码');
				return false;
		} else {
				if (!checkPwd(password)) {
					return falae;
				}
		}

		if (!isDefine(rePassword)) {
				$toast('请填写确认密码');
				return false;
		} else {
				if (!checkPwd(rePassword)) {
					return falae;
				}
		}

		if (!recheckpayPwd(password, rePassword)) {
				$toast('两次密码输入不一致');
				return false;
		}
		ajax({
				url: Config.user.resetPwd,
				data: {
					mobile: mobile,
					password: password,
					rePassword: rePassword,
					companyId: company_id
				}
		}, function(data) {
				if (data.code == 1) {
					$alert('重置密码成功！',function(){
							//移除存在本地的手机号码
							$api.rmStorage('mobile')
							$api.clearStorage();
							api.openWin({
								name: 'login',
								url: './login.html',
								slidBackEnabled: false
							});
					});
				} else {
						$toast(data.msg);
				}
		});
	}
</script>
